import BaseRequest, {ApiResponse} from '@/shared/utils/request'
import { HOSTS } from '@/shared/constants/index'
import {UserModel, WxLoginResponse} from "@/shared/services/model/user";
import {RechargeModel} from "@/shared/services/model/recharge";
import {CostOrderModel} from "@/shared/services/model/order";

/**
 * 服务类示例
 */
class UserService extends BaseRequest {
	constructor() {
		super({
			hostKey: HOSTS.TARO_API_BASE,
		})
	}

	/**
	 * 一个获取某项数据的 get 请求
	 */
  wxLogin(payload: any): Promise<ApiResponse<WxLoginResponse>> {
    return this.post<WxLoginResponse>({
      url: '/api/v1/auth/wxlogin',
      data: payload,
    })
  }

  userInfo(payload: any): Promise<ApiResponse<UserModel>> {
    return this.get<UserModel>({
      url: '/api/v1/auth/userInfo',
      data: payload,
    })
  }

  recharge(payload: any): Promise<ApiResponse<RechargeModel>> {
    return this.post<RechargeModel>({
      url: '/api/v1/admin/recharge',
      data: payload,
    })
  }

  cost(payload: any): Promise<ApiResponse<RechargeModel>> {
    return this.post<RechargeModel>({
      url: '/api/v1/admin/buy',
      data: payload,
    })
  }

  costOrderList(payload: any): Promise<ApiResponse<CostOrderModel[]>> {
    return this.get<CostOrderModel[]>({
      url: '/api/v1/user/chagre/list',
      data: payload,
    })
  }
}

export default new UserService()
